use crossterm::{terminal, Result};

mod editor;
use editor::Editor;

fn main() -> Result<()> {
  let editor = Editor::new()?;

  terminal::enable_raw_mode()?;
  loop {
    if editor.refresh_screen().is_err() {
      editor.die("unable to refresh screen");
    }

    if editor.process_keypress() {
      break;
    }
  }
  terminal::disable_raw_mode()?;

  Ok(())
}
